import request from './request'

// 登录
export const login = (data) => {
  return request({
    url: '/auth/login/',
    method: 'post',
    data
  })
}

// 获取用户信息
export const getUserInfo = () => {
  return request({
    url: '/auth/user-info/',
    method: 'get'
  })
}

// 登出
export const logout = () => {
  return request({
    url: '/auth/logout/',
    method: 'post'
  })
}

// 刷新token
export const refreshToken = (refresh_token) => {
  return request({
    url: '/auth/refresh/',
    method: 'post',
    data: { refresh: refresh_token }
  })
}

// 更新用户资料
export const updateProfile = (data) => {
  return request({
    url: '/auth/update-profile/',
    method: 'put',
    data
  })
}

// 修改密码
export const changePassword = (data) => {
  return request({
    url: '/auth/change-password/',
    method: 'post',
    data
  })
}

// 上传头像
export const uploadAvatar = (formData) => {
  return request({
    url: '/auth/upload-avatar/',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
